using System;
using System.Globalization;
using System.IO;

namespace Atomic.Vasp.Options
{
	/// <summary>
	/// Gaussian smearing (ISMEAR=0 and SIGMA).
	/// </summary>
	[Serializable]
	public class GaussianSmearing : VaspOption
	{
		public GaussianSmearing()
			: this(null)
		{
		}

		public GaussianSmearing(double? sigma)
		{
			if (sigma.HasValue && sigma.Value <= 0.0)
			{
				throw new ArgumentException();
			}

			Sigma = sigma;
		}

		public override void Write(VaspIncar incar, DirectoryInfo directory)
		{
			incar.Add("ISMEAR", "0", "Gaussian smearing");

			if (Sigma.HasValue)
			{
				incar.Add("SIGMA", Sigma.Value.ToString(CultureInfo.InvariantCulture));
			}
		}

		public double? Sigma
		{
			get;
			private set;
		}
	}
}
